﻿using System;

public class LightIntensity
{
    public double r;
    public double g;
    public double b;
	public LightIntensity()
	{
        this.r = 0;
        this.g = 0;
        this.b = 0;
	}
    public LightIntensity(LightIntensity l)
    {
        this.r = l.r;
        this.g = l.g;
        this.b = l.b;
    }
    public LightIntensity(double r, double g, double b)
    {
        this.r = r;
        this.g = g;
        this.b = b;
    }
    public LightIntensity(double r, double g)
    {
        this.r = r;
        this.g = g;
        this.b = 0;
    }
    public LightIntensity(double r)
    {
        this.r = r;
        this.g = 0;
        this.b = 0;
    }
    public static LightIntensity operator +(LightIntensity li1, LightIntensity li2)
    {
        return new LightIntensity(li1.r + li2.r, li1.g + li2.g, li1.b + li2.b);
    }
    public static LightIntensity operator -(LightIntensity li1, LightIntensity li2)
    {
        return new LightIntensity(li1.r - li2.r, li1.g - li2.g, li1.b - li2.b);
    }
    public static LightIntensity operator /(LightIntensity li, float n)
    {
        if(n!=0)
            return new LightIntensity(li.r / n, li.g / n, li.b / n);
        else
            return new LightIntensity();
    }
    public static LightIntensity operator *(LightIntensity li1, LightIntensity li2)
    {
        return new LightIntensity(li1.r * li2.r, li1.g * li2.g, li1.b * li2.b);
    }
    public static LightIntensity operator *(LightIntensity li, float n)
    {
        return new LightIntensity(li.r * n, li.g * n, li.b * n);
    }
    //public static LightIntensity operator *(float n, LightIntensity li);
    public void add(double r, double g, double b)
    {
        this.r += (r >= 0.0) ? r : 0.0;
        this.g += (g >= 0.0) ? g : 0.0;
        this.b += (b >= 0.0) ? b : 0.0;
    }
    public override string ToString()
    {
        return ("R:"+this.r+",G:"+this.g+",B:"+this.b);
    }
}
